import 'package:flutter/material.dart';

class RadioGroupDemo extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => RadioState();
}

class RadioState extends State<RadioGroupDemo> {
  int _radioGroupItemValue = 0;

  int _radioGroupItemValueA = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('RadioGroupDemo'),
        elevation: 0.0,
      ),
      body: Container(
        padding: EdgeInsets.all(16.0),
        child: Column(
          children: <Widget>[
            Text('RadioListTile value = $_radioGroupItemValueA'),
            SizedBox(
              height: 32.0,
            ),
            RadioListTile(
              value: 0,
              groupValue: _radioGroupItemValueA,
              onChanged: (value) {
                setState(() {
                  _radioGroupItemValueA = value;
                });
              },
              title: Text('RadioGroup0'),
              subtitle: Text('Radio subTitle0'),
              secondary: Icon(Icons.accessibility_new),
              selected: _radioGroupItemValueA == 0 ,
              activeColor: Colors.blue,
            ),
            RadioListTile(
              value: 1,
              groupValue: _radioGroupItemValueA,
              title: Text('RadioGroup1'),
              subtitle: Text('RadioGroup subTitle1'),
              onChanged: (value) {
                setState(() {
                  _radioGroupItemValueA = value;
                });
              },
              activeColor: Colors.blue,
              secondary: Icon(Icons.accessibility_new),
              selected: _radioGroupItemValueA == 1,
            ),
            Row(
              children: <Widget>[
                Radio(
                  value: 0,
                  groupValue: _radioGroupItemValue,
                  onChanged: (value) {
                    setState(() {
                      _radioGroupItemValue = value;
                    });
                  },
                  activeColor: Colors.blue,
                ),
                Radio(
                  value: 1,
                  groupValue: _radioGroupItemValue,
                  onChanged: (value) {
                    setState(() {
                      _radioGroupItemValue = value;
                    });
                  },
                  activeColor: Colors.blue,
                )
              ],
            )
          ],
        ),
      ),
    );
  }
}
